<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class HttpRequest {
	/**
	 * Constructeur
	 * @param unknown_type $getParams
	 * @param unknown_type $postParams
	 */
	public function HttpRequest($getParams, $postParams) {
		foreach ($getParams as $k=>$v) $this->$k = $v;
		foreach ($postParams as $k=>$v) $this->$k = $v;
	}

	/**
	 * Enter description here ...
	 * @param unknown_type $var
	 * @param unknown_type $defVal
	 * @return unknown
	 */
	private function getVar($var, $defVal = null) {
		return (isset($this->$var) && $this->$var != 'undefined' && $this->$var != '')?$this->$var:$defVal;
	}

	/**
	 * Enter description here ...
	 * @param unknown_type $var
	 * @param unknown_type $defVal
	 * @return unknown
	 */
	private function booleanval($val) {
		$tabTrue = array('true','ok','oui','yes','y','1','on');
		if (!isset($var)) return false;
		elseif (is_string($val)) return (in_array(strtolower($val),$tabValue,true));
		elseif (is_numeric($var)) return ($var > 0);
		elseif (is_bool($var)) return $var;
		else return (isset($var));
		return false;
	}

	/**
	 * Enter description here ...
	 * @param unknown_type $var
	 * @param unknown_type $defVal
	 */
	public function getString($var, $defVal = null) {
		return $this->getVar($var, $defVal);
	}

	/**
	 * Enter description here ...
	 * @param unknown_type $var
	 * @param unknown_type $defVal
	 */
	public function getInt($var, $defVal = 0) {
		return intval($this->getVar($var, $defVal));
	}

	/**
	 * Enter description here ...
	 * @param unknown_type $var
	 * @param unknown_type $defVal
	 */
	public function getBool($var, $defVal = false) {
		return booleanval($this->getVar($var, $defVal));
	}

	/**
	 * Enter description here ...
	 */
	public function getScreen() {
		if (isset($this->scr) && $this->scr != "")
			return $this->scr;
		return Config::getParams()->HOME_SCREEN;
	}
	
	/**
	 * Renvoie vrai s'il s'agit d'un requete DS
	 */
	public function isDataSourceRequest() {
		return isset($this->_dataSource);
	}
	
	/**
	 * Renvoie vrai en cas de requete d'authentification
	 */
	public function isAuthenticationRequest() {
		return isset($this->_authRequest);
	}
	
	/**
	 * Enter description here ...
	 */
	public function getDataSource() {
		return $this->_dataSource;
	}
}
?>
